﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Comic.Common
{
    /// <summary>The Interface for a Plugin (Comic-Provider)</summary>
    public interface iComicProvider
    {
        /// <summary>
        /// Event fired on BannerChangeRequest (during download or display)
        /// </summary>
        event BannerChangeDelegate BannerChangeEvent;

        /// <summary>
        /// Event fired on Sync-Progress change
        /// </summary>
        event SyncProgressChangeDelegate SyncProgressChangeEvent;
        /// <summary>
        /// ISO-String for the current Display-Language
        /// </summary>
        string GuiLanguage
        {
            get;
            set;
        }

        /// <summary>
        /// The current Version-Number for the Plugin
        /// </summary>
        Version PluginGetVersion();

        /// <summary>
        /// Name for the Plugin
        /// </summary>
        string PluginGetName();

        /// <summary>
        /// Read the Plugin-Settings (GUI-Controls) for Config-Edit
        /// </summary>
        List<cSettingControl> PluginGetSettings();

        /// <summary>
        /// Save the Plugin-Settings to plugin-internal Memory
        /// </summary>
        /// <param name="SettingControls">The Setting-Controls with the values to save</param>
        bool PluginSaveSettings(System.Collections.Generic.List<Comic.Common.cSettingControl> SettingControls);

        /// <summary>
        /// Run the Offline-Sync for the Comic in Background
        /// </summary>
        bool PluginRunDataSyncAsync();

        /// <summary>
        /// Move internal Index to the next Page
        /// </summary>
        void PageGoNext();

        /// <summary>
        /// Move internal Index to the first Page
        /// </summary>
        void PageGoFirst();

        /// <summary>
        /// Move internal Index to the previous Page
        /// </summary>
        void PageGoPrevious();

        /// <summary>
        /// Indicates first Page
        /// </summary>
        bool PageIsFirst();

        /// <summary>
        /// Indicates last Page
        /// </summary>
        bool PageIsLast();

        /// <summary>
        /// Get the Content for the current Page (using internal Index) for GUI-Display
        /// </summary>
        cComicPage PageGetCurrent();

        /// <summary>
        /// Indicates if Chapters are available
        /// </summary>
        /// <remarks>If FALSE all Chapter-Functions in the Viewer are disabled for the Plugin</remarks>
        /// <returns>TRUE if Chapters are supported, FALSE if not</returns>
        bool ChapterAvailable();

        /// <summary>
        /// Indicates first Chapter
        /// </summary>
        bool ChapterIsFirst();

        /// <summary>
        /// Indicates last Chapter
        /// </summary>
        bool ChapterIsLast();

        /// <summary>
        /// Move internal Index to the first Page of the next Chapter
        /// </summary>
        void ChapterGoNext();

        /// <summary>
        /// Move internal Index to the first Page of the previous Chapter
        /// </summary>
        void ChapterGoPrevious();

        /// <summary>
        /// Move internal Index to the first Page of the first Chapter
        /// </summary>
        void ChapterGoFirst();

        /// <summary>
        /// Move internal Index to the first Page of the last Chapter
        /// </summary>
        void ChapterGoLast();

        /// <summary>
        /// Move internal Index to the last Page
        /// </summary>
        void PageGoLast();

        /// <summary>
        /// The list of Pages in the Plugin-Library
        /// </summary>
        List<sComicPageSummary> PluginGetPageList();

        /// <summary>
        /// Load a defined Page by it's ID (Index)
        /// </summary>
        /// <param name="PageID">The ID for the Page to load</param>
        void PageGoToID(int PageID);

        /// <summary>
        /// The About-Content for the Plugin (RichtText)
        /// </summary>
        string PluginGetAboutRTF();

        /// <summary>
        /// Get the URL for the Comic-Homepage
        /// </summary>
        string PluginGetWebComicPageUrl();

        /// <summary>
        /// Apply a rating to the current Page
        /// </summary>
        /// <param name="PageID">the ID for the Page to change</param>
        /// <param name="PageRating">the new Rating (0-5) for the Page</param>
        bool PageSetRating(int PageID, int PageRating);

        /// <summary>
        /// Move internal Index to the first Page of the current Chapter
        /// </summary>
        void ChapterGoFirstPage();

        /// <summary>
        /// The License-Content for the Plugin (RichtText)
        /// </summary>
        string PluginGetContentLicenseRTF();

        /// <summary>
        /// The Minimum Version of Application-Core to use this Plugin
        /// </summary>
        System.Version PluginMinCoreVersion();

        /// <summary>
        /// Move the local Library (Data) of Plugin to another Folder (called if User changes Data-Dir)
        /// </summary>
        /// <param name="OldDataRootPath">current Data-Root-Path for Plugins</param>
        /// <param name="NewDataRootPath">new Data-Root-Path for Plugins</param>
        void PluginMoveLocalContent(string OldDataRootPath, string NewDataRootPath);

        /// <summary>
        /// Initialize the Plugin
        /// </summary>
        /// <param name="PluginDataRoot">The Data-Root for the Application-Plugins (must be extended by a subfolder with unique name for usage)</param>
        void PluginInitialize(string PluginDataRoot);

        /// <summary>
        /// If returns TRUE this indicates the Plugin does not support offline-reading (no sync possible; no BannerChangeEvent)
        /// </summary>
        bool PluginViewOnlineOnly();

        /// <summary>
        /// Get the Plugin Icon
        /// </summary>
        System.Drawing.Icon PluginGetIcon();

        /// <summary>
        /// Re-Download the Content for the current Page (used online and offline)
        /// </summary>
        void PageReDownload();

        /// <summary>
        /// Get the List of all Pages in offline library (for direct navigation in GUI)
        /// </summary>
        List<sComicPageSummary> PagesGetOverviewList();

        /// <summary>
        /// For uninstall of Plugin: delete all local data including directory
        /// </summary>
        void PluginDeleteLocalContent();
    }
}